//小鱼绘制
var babyObj = function () 
{
	this.x;
	this.y;
	this.angle;
	this.babyBoby = new Image();

	this.babyTailTimer = 0;
	this.babyTailCount = 0;

	this.babyEyeTimer = 0;
	this.babyEyeCount = 0;
	this.babyEyeInterval = 1000;

	this.babyBobyTimer = 0;
	this.babyBobyConut = 0;
}
babyObj.prototype.init = function() 
{
	this.x = canWidth * 0.5 - 50;
	this.y = canHeight * 0.5 + 50;
	this.angle = 0;
	this.babyBoby.src = "img/babyFade0.png";
}
babyObj.prototype.draw = function()
{
	//lerp x,y
	this.x = lerpDistance(mom.x,this.x, 0.98);
	this.y = lerpDistance(mom.y,this.y, 0.98);

	//lerp angle
	var deltaY = mom.y - this.y;
	var deltaX = mom.x - this.x;
	var beta = Math.atan2(deltaY,deltaX) + Math.PI;

	//lerp angle
	this.angle = lerpAngle(beta,this.angle,0.6);//鼠标角度的快慢

	//计数工作 尾巴动画
	this.babyTailTimer  += deltaTime;
	if (this.babyTailTimer > 50)
	{
		this.babyTailCount = (this.babyTailCount + 1) % 8;
		this.babyTailTimer %= 50;
	}
	//小鱼眼睛
	this.babyEyeTimer += deltaTime;
	if (this.babyEyeTimer > this.babyEyeInterval) 
	{
		this.babyEyeCount = (this.babyEyeCount + 1) % 2;
		this.babyEyeTimer %= this.babyEyeInterval;

		if (this.babyEyeCount == 0) 
		{
			this.babyEyeInterval = Math.random() * 1500 + 2000;
		}else
		{
			this.babyEyeInterval = 200;
		}
	}

	this.babyBobyTimer += deltaTime;
	if (this.babyBobyTimer  > 600)
	{
		this.babyBobyConut = this.babyBobyConut + 1;
		this.babyBobyTimer %= 600;
		if (this.babyBobyConut > 19)
		{
			this.babyBobyConut = 19;
			//game over
			data.gameOver = true;
		}
	}

	ctx1.save();
	//translate()
	ctx1.translate(this.x,this.y);
	ctx1.rotate(this.angle);

	var babyTailCount = this.babyTailCount;
	ctx1.drawImage(babyTail[babyTailCount],- babyTail[babyTailCount].width * 0.5 + 23,- babyTail[babyTailCount].height * 0.5);
	var babyBobyConut = this.babyBobyConut;
	ctx1.drawImage(babyBoby[babyBobyConut],- babyBoby[babyBobyConut].width * 0.5,- babyBoby[babyBobyConut].height * 0.5);
	var babyEyeCount = this.babyEyeCount;
	ctx1.drawImage(babyEye[babyEyeCount],- babyEye[babyEyeCount].width * 0.5,- babyEye[babyEyeCount].height * 0.5);
	
	

	ctx1.restore();
}